package com.pybox.repository;

import com.pybox.dto.TObjectsCabinetDto;
import com.pybox.entity.TObjects;
import com.pybox.entity.TObjectsCabinet;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.awt.print.PrinterGraphics;
import java.util.List;

/**
* 描述：TObjectsCabinet Repository
* @author wuyingkai
* @date 2018-09-15
*/

@Repository
public interface TObjectsCabinetRepository extends JpaRepository<TObjectsCabinet, Integer>, JpaSpecificationExecutor<TObjectsCabinet>   {

    List<TObjectsCabinet> findAllByUkeyUuid(String ukeyuuid);

    @Query( value = "select id from t_objects_cabinet where object_id=?1",nativeQuery = true)
    List<Integer> getIdsByObjectId(Integer objectId);

    @Modifying
    @Query(value = " delete from t_objects_cabinet where ukey_uuid=?1" ,nativeQuery = true)
    Integer deleteByObjectId(String objId);

    List<TObjectsCabinet> findAllByCabinetUUId(String uuid);

    @Query(value = "select count(uuid) from t_objects  where cabinet_uid=?1 and deleted =0 and status =1",nativeQuery = true)
    Integer getObjectCountByCabinetUUID(String cabinetUUID);
}